/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include "Envelope.h"

#include "Keys.h"
#include "EnvelopeTemplates.h"
#include <string>
#include <Converter.h>
#include <xml/Stream.h>

namespace liba
{
namespace animate
{

converter::EnumPair<char,EnvelopeBase::Behavior> EnvelopeBase::BehaviorNames[] = 
{
	converter::MakeEnumPair("CONSTANT",EnvelopeBase::CONSTANT),
	converter::MakeEnumPair("REPEAT",EnvelopeBase::REPEAT),
	converter::MakeEnumPair("OSCILLATE",EnvelopeBase::OSCILLATE),
	converter::MakeEnumPair("OFFSET",EnvelopeBase::OFFSET),
	converter::MakeEnumPair("LINEAR",EnvelopeBase::LINEAR),
	0
};

bool EnvelopeBase::on_attribute( xml::Provider * prov, const std::string & name, const std::string & value )
{
	if( name == "PreBehave" )
	{
		return converter::convert( value, &behavior[0] );
	}
	if( name == "PostBehave" )
	{
		return converter::convert( value, &behavior[1] );
	}
	return false;
}

} // namespace animate

} //namespace liba
